package com.example.foods.service.impl;

import com.example.foods.data.CustomersMapper;
import com.example.foods.domain.CustomersInfo;
import com.example.foods.domain.UpdatePwdInfo;
import com.example.foods.entity.Customers;
import com.example.foods.service.CustomerService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service

@Transactional
public class CustomerImpl implements CustomerService {

    @Resource
    private CustomersMapper customersMapper;

    @Override
    public CustomersInfo findBycst(String cst) {
        Customers customers = this.customersMapper.findByCustomers(cst);
        CustomersInfo customersInfo = null;
        if (customers != null) {
            customersInfo = new CustomersInfo();
            customersInfo.setCst_Id(customers.getCstId());
            customersInfo.setCst_pwd(customers.getCstPwd());
            customersInfo.setCst_mobile(customers.getCstMobile());
        }
        return customersInfo;
    }

    @Override
    public void updatePwd(UpdatePwdInfo updatePwdInfo) {
        Customers customers = new Customers();
        customers.setCstMobile(updatePwdInfo.getUserId());
        customers.setCstPwd(updatePwdInfo.getPwd());
        customersMapper.updatePwd(customers);
    }

}
